package operation;
import  book.booklist;
import book.book;

import java.util.Scanner;

public class del implements ioperation{
    public void work(booklist booklist){
        System.out.println("del");
        System.out.println("请输入要删除的名字");
        int j=0;
        int i=0;
        Scanner scanner =new Scanner(System.in);
        String name =scanner.nextLine();
        int currentsize=booklist.getUsedsize();
        for(;i<currentsize;i++){
            book book = booklist.gettops(i);
            if(book.getName().equals(name)){
                System.out.println("find");
                j=i;
                break;
            }
        }
        if(i==currentsize){
            System.out.println("nofind");
        }
        for(int m=j;m<currentsize;m++){
            book book =booklist.gettops(m+1);
            booklist.setBooks(m,book);
        }
        booklist.setBooks(currentsize-1,null);
        booklist.setUsedsize(currentsize-1);
    }
}